using System;
using System.Collections;
using System.Data;
using CE.Database;
using CE.Security;
/// <summary>
/// Summary description for UserProfileDB
/// </summary>
/// 
namespace CE.User
{
    public class ProfileDB
    {
        public ProfileDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public Int64 Insert(Profile profile)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "sprocUserProfileInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@ProfileID", profile.ProfileId);
            _sPara.Add("@Salutation", profile.Salutation);
            _sPara.Add("@Name", profile.Name);
            _sPara.Add("@ContactNumber", profile.ContactNumber);
            _sPara.Add("@DOB", profile.DOB);
            _sPara.Add("@Qualification", profile.Qualification);
            _sPara.Add("@YearsExperience", profile.YearsExperience);
            _sPara.Add("@SalesExperience", profile.SalesExperience);
            _sPara.Add("@EmploymentStatus", profile.EmploymentStatus);
            _sPara.Add("@PreferredCountry", profile.PreferredCountry);
            _sPara.Add("@AttachCV", profile.AttachCV);
            _sPara.Add("@Occupation", profile.Occupation);
            _sPara.Add("@VoiceRecord", profile.VoiceRecord);
            _sPara.Add("@RefUserId", profile.RefUserId);
            _sPara.Add("@Status", profile.Status);
            _sPara.Add("@Info1", profile.Info1);
            _sPara.Add("@Info2", profile.Info2);
            _sPara.Add("@Info3", profile.Info3);
            _sPara.Add("@Info4", profile.Info4);
            _sPara.Add("@Info5", profile.Info5);
            _sPara.Add("@Info6", profile.Info6);
            _sPara.Add("@Info7", profile.Info7);
            _sPara.Add("@Info8", profile.Info8);
            _sPara.Add("@Info9", profile.Info9);
            _sPara.Add("@Info10", profile.Info10);
            _sPara.Add("@Info11", profile.Info11);
            _sPara.Add("@Info12", profile.Info12);
            _sPara.Add("@Info13", profile.Info13);
            _sPara.Add("@Info14", profile.Info14);
            _sPara.Add("@Info15", profile.Info15);
            _sPara.Add("@Info16", profile.Info16);
            _sPara.Add("@Info17", profile.Info17);
            _sPara.Add("@Info18", profile.Info18);
            _sPara.Add("@Info19", profile.Info19);
            _sPara.Add("@Info20", profile.Info20);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Profile GetProfile(Int64 RefUserId)
        {
            MyDatabase _Db = new MyDatabase();
            string _spName = "sprocUserProfileSelectSingleItem";
            Profile _result = null;
            DataTable _dt;
            SortedList _sPara = new SortedList();

            _sPara.Add("@RefUserId", RefUserId);

            _dt = _Db.GetDataTableBySP(_spName, _sPara);

            if (_dt != null && _dt.Rows.Count > 0)
            {
                _result = new Profile();
                _result = FillDataRecord(_dt);
            }

            return _result;
        }
        public bool Update()
        {
            return true;
        }

        public bool Delete()
        {
            return true;
        }

        private Profile FillDataRecord(DataTable myDataTable)
        {
            Profile myProfile = new Profile();
            myProfile.ProfileId = Convert.ToInt64(myDataTable.Rows[0]["ProfileID"].ToString());
            myProfile.RefUserId = Convert.ToInt64(myDataTable.Rows[0]["RefUserId"].ToString());
            myProfile.Salutation = myDataTable.Rows[0]["Salutation"].ToString();
            myProfile.Name = myDataTable.Rows[0]["Name"].ToString();
            myProfile.ContactNumber = myDataTable.Rows[0]["ContactNumber"].ToString();
            myProfile.DOB = Convert.ToDateTime(myDataTable.Rows[0]["DOB"].ToString());
            myProfile.Qualification = myDataTable.Rows[0]["Qualification"].ToString();
            myProfile.YearsExperience = myDataTable.Rows[0]["YearsExperience"].ToString();
            myProfile.SalesExperience = myDataTable.Rows[0]["SalesExperience"].ToString();
            myProfile.EmploymentStatus = myDataTable.Rows[0]["EmploymentStatus"].ToString();
            myProfile.PreferredCountry = myDataTable.Rows[0]["PreferredCountry"].ToString();
            myProfile.AttachCV = myDataTable.Rows[0]["AttachCV"].ToString();
            myProfile.Occupation = myDataTable.Rows[0]["Occupation"].ToString();
            myProfile.VoiceRecord = myDataTable.Rows[0]["VoiceRecord"].ToString();
            myProfile.CreatedDate = Convert.ToDateTime(myDataTable.Rows[0]["CreatedDate"].ToString());
            myProfile.ModifiedDate = Convert.ToDateTime(myDataTable.Rows[0]["ModifiedDate"].ToString());

            myProfile.Status = myDataTable.Rows[0]["Status"].ToString();
            myProfile.Info3 = myDataTable.Rows[0]["Info3"].ToString();
            return myProfile;
        }
    }
}